package com.itxiuyixiu.security.config;

import com.itxiuyixiu.tools.security.handler.ApiLoginFailureHandler;
import com.itxiuyixiu.tools.security.handler.ApiLoginSuccessHandler;
import com.itxiuyixiu.tools.security.handler.ApiLogoutSuccessHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author 黄磊
 * @date 2020/5/1
 */
@Configuration
public class SecurityConfig {
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public ApiLoginSuccessHandler apiLoginSuccessHandler() {
        return new ApiLoginSuccessHandler();
    }

    @Bean
    public ApiLoginFailureHandler apiLoginFailureHandler() {
        return new ApiLoginFailureHandler();
    }

    @Bean
    public ApiLogoutSuccessHandler apiLogoutSuccessHandler() {
        return new ApiLogoutSuccessHandler();
    }
}
